package com.example.compreshensiveshop.controller;


import com.example.compreshensiveshop.common.JsonResponse;
import com.example.compreshensiveshop.dto.LoginDTO;
import com.example.compreshensiveshop.dto.PasswordUpdateDTO;
import com.example.compreshensiveshop.dto.RegisterDTO;
import com.example.compreshensiveshop.service.UserService;
import com.example.compreshensiveshop.vo.SellerLoginVO;

import com.example.compreshensiveshop.vo.UserVO;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;




@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 测试是否包含token
     *
     * @return
     */
    @GetMapping("/csToken")
    public boolean csToken() {
        return true;
    }

    /**
     * 用户注册接口
     *
     * @param registerDTO
     * @return
     */

    @PostMapping("/register")
    public JsonResponse<UserVO> register(@RequestBody RegisterDTO registerDTO) {
        return userService.register(registerDTO);
    }

    /**
     * 用户登录接口
     *
     * @param loginDTO
     * @return
     */
    @PostMapping("/login")
    public JsonResponse<UserVO> login(@RequestBody LoginDTO loginDTO) {
        return userService.login(loginDTO);
    }

    /**
     * 商家登录接口
     *
     * @param loginDTO
     * @return
     */
    /*商家登录接口*/
    @PostMapping("/sellerLogin")
    public JsonResponse<SellerLoginVO> sellerLogin(@RequestBody LoginDTO loginDTO) {
        return userService.sellerLogin(loginDTO);
    }

    /**
     * 密码修改
     *
     * @param passwordUpdateDTO
     * @return
     */
    /*密码修改*/
    @PutMapping("/updatePassword")
    public JsonResponse<UserVO> updatePassword(@RequestBody PasswordUpdateDTO passwordUpdateDTO) {
        return userService.updatePassword(passwordUpdateDTO);
    }
}
